<template>
    <h1>vuex页面</h1>
    <P>count : {{ count }}</P>
    <p>temTimes: {{ temTimes }}</p>
    <button @click="updateVuexCount">修改count</button>
    <button @click="asyncIncrement">修改count-action</button>

    <p>moduleA: countA {{ store.state.a.countA }}</p>
    <p>moduleB: countB {{ store.state.b.countB }}</p>

    <p>moduleA: doubleCountA {{ store.getters.doubleCountA }}</p>
    <p>moduleB: doubleCountB {{ store.getters['b/doubleCountB'] }}</p>

    <button @click="moduleAincrementA">模块A-mutation-触发</button>
    <button @click="moduleBincrementB">模块B-mutation-触发</button>

    <button @click="moduleAasyncIncrementA">模块A-action-触发</button>
    <button @click="moduleAasyncIncrementB">模块B-action-触发</button>

    <button @click="moduleBemitGlobaMut">模块B出发全局-mut</button>
    <button @click="moduleBemitGlobaAct">模块B出发全局-act</button>

</template>

<script setup>
import { computed } from 'vue'
import { useStore } from 'vuex'

const store = useStore()

const count = computed(() => store.state.count)
const tenTimes = computed(() => state.getters.tenTimes)

const updateVuexCount = () => {
    store.commit("increment", {count:24})
}

const asyncIncrement = () => store.dispatch('asyncIncrement',{count:30})
//
const moduleAincrementA = () =>{
    store.commit('incrementA')
}

const moduleBincrementB = () =>{
   store.commit('b/incrementB')
}
//
const moduleAasyncIncrementA = () => {
    store.dispatch('asyncIncrementA')
}

const moduleAasyncIncrementB = () => {
    store.dispatch('b/asyncIncrementB')
}

const moduleBemitGlobaMut = () =>{
    store.dispatch('b/emitGlobalMut')
}

const moduleBemitGlobaAct = () =>{
    store.dispatch('b/emitGlobalAct')
}

</script>

<style scoped>

</style>